package com.zlp.controller;

import com.zlp.common.api.Result;
import com.zlp.dto.test.SupplierBaseDTO;
import com.zlp.dto.test.SupplierCouponReq;
import com.zlp.entity.User;
import com.zlp.enums.CouponTypeEnum;
import com.zlp.enums.StatusEnum;
import com.zlp.enums.SupplierFactoryEnum;
import com.zlp.enums.SupplierTypeEnum;
import com.zlp.stategy.CouponSupplierStategy;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description 枚举控制层
 * @Classname EnumController
 * @Date 2022/12/3 16:31
 * @Created by ZouLiPing
 */
@RequiredArgsConstructor
@Api(value = "enum", tags = "枚举模块")
@RestController
public class EnumController {



    /**
     * 业务编码枚举
     * @author ZouLiPing
     * @date 2022/11/29 10:36
     */
    @ApiOperation( "业务编码")
    @GetMapping(value = "getStatusEnum")
    public Result<User> getStatusEnum(){
        User user = new User();
        user.setStatus(StatusEnum.NORMAL.getValue());
        return Result.success(user);
    }

    /**
     * 枚举属性
     * @author ZouLiPing
     * @date 2022/11/29 10:36
     */
    @ApiOperation( "业务编码")
    @GetMapping(value = "getEnumProperties")
    public Result<String> getEnumProperties(){
        String name = SupplierTypeEnum.getName(SupplierTypeEnum.LI_HAN.getCode());
        return Result.success(name);
    }


    /**
     * 业务枚举
     * @author ZouLiPing
     * @date 2022/11/29 10:36
     */
    @ApiOperation( "业务枚举")
    @GetMapping(value = "getbusinessEnum")
    public Result<List<String>> getbusinessEnum(){
        List companyList = CouponTypeEnum.getCompanyList(CouponTypeEnum.LI_HAN.getCode());
        return Result.success(companyList);
    }


    /**
     * 枚举工厂
     * @author ZouLiPing
     * @date 2022/11/29 10:36
     */
    @ApiOperation( "枚举工厂")
    @PostMapping(value = "getEnumFactory")
    public Result<List<SupplierBaseDTO>> getEnumFactory(@RequestBody SupplierCouponReq supplierCouponReq){

        CouponSupplierStategy service = SupplierFactoryEnum.getService(CouponTypeEnum.LI_HAN.getCode());
        List<SupplierBaseDTO> couponBaseInfo = service.getCouponBaseInfo(supplierCouponReq);
        return Result.success(couponBaseInfo);
    }


}
